#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>

#include "tools.filesystem.h"

using namespace jolfs;

template <typename T>
std::string print_vector( const std::vector<T>& v )
{
  std::string result = "[ ";
  typename std::vector<T>::const_iterator it = v.begin();
  for (; it!=v.end(); ++it )
  {
    if ( it != v.begin() )
      result += ", ";
    result += *it;
  }
  result += " ]";
  
  return result;
}

int main( int argc, char** argv )
{
  std::string paths[] = 
  {
    "/this/is/a/test",
    "/",
    "",
    "/test",
    "test",
    "/an/other.test",
    "/and/.again",
    ".a_last_one"
  };
  
  for ( unsigned short i=0; i<sizeof(paths)/sizeof(std::string); ++i )
    std::cout << "filename(\"" << paths[i] << "\") = \"" << filename(paths[i]) << "\"" << std::endl;

  std::cout << "---" << std::endl;
  
  for ( unsigned short i=0; i<sizeof(paths)/sizeof(std::string); ++i )
    std::cout << "extension(\"" << paths[i] << "\") = \"" << extension(paths[i]) << "\"" << std::endl;

  std::cout << "---" << std::endl;
  
  for ( unsigned short i=0; i<sizeof(paths)/sizeof(std::string); ++i )
    std::cout << "explode(\"" << paths[i] << "\") = " << print_vector(explode(paths[i])) << std::endl;

  std::cout << "---" << std::endl;
  
  for ( unsigned short i=0; i<sizeof(paths)/sizeof(std::string); ++i )
    std::cout << "implode(explode(\"" << paths[i] << "\")) = " << implode(explode(paths[i])) << std::endl;

  std::cout << "---" << std::endl;
  
  for ( unsigned short i=0; i<sizeof(paths)/sizeof(std::string); ++i )
    std::cout << "directory(\"" << paths[i] << "\") = \"" << directory(paths[i]) << "\"" << std::endl;

  return EXIT_SUCCESS;
}